package cn.com.surker.base.strength.service.impl;

import cn.com.surker.base.strength.entity.BaseStrengthLevel;
import cn.com.surker.base.strength.dao.BaseStrengthLevelDao;
import cn.com.surker.base.strength.service.StrengthLevelBaseService;
import cn.com.surker.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.List;

/**
* <p>
    * 强度等级基础表 服务实现类
    * </p>
*
* @author admin
* @since 2024-08-01
*/
public abstract class StrengthLevelBaseServiceImpl extends ServiceImpl<BaseStrengthLevelDao, BaseStrengthLevel> implements StrengthLevelBaseService {

    @Resource
    protected BaseStrengthLevelDao strengthLevelDao;

    /**
     * 根据类型查询等级
     * @param type
     * @return
     */
    public List<BaseStrengthLevel> findLevel(Integer type) {
        QueryWrapper<BaseStrengthLevel> query = new QueryWrapper<>();
        query.eq("status", 0);
        if (!StringUtils.isNull(type))
            query.eq("type", type);
        query.orderByAsc("level");
        List<BaseStrengthLevel> list = strengthLevelDao.selectList(query);
        if (list == null || list.size() == 0)
            return null;
        return list;
    }

    /**
     * 查询没有设置容重区间的基础标号信息
     * @param orgId
     * @return
     */
    public List<BaseStrengthLevel> findStrengthOrDosage(Long orgId) {
        if (StringUtils.isNull(orgId))
            return null;
        return strengthLevelDao.findStrengthOrDosage(orgId);
    }

}